<!--
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 14:41:20
 * @LastEditTime: 2023-08-17 15:10:11
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description:   :gridOps="gridOptions" 
-->
<template>
	<sc-VxeTable
		ref="xGrid1"
		:gridEvts="gridEvents"
		:tablecode="'pro_dept'"
		:url="this.$API.pro.dept.list"
	>
	</sc-VxeTable>

	<save-dialog
		v-if="dialog.save"
		ref="saveDialog"
		@success="handleSuccess"
		@closed="dialog.save = false"
	>
	</save-dialog>
</template>
<script>
import SaveDialog from "./save";
export default {
	components: {
		SaveDialog,
	},
	name: "pro_dept",
	data() {
		return {
			dialog: {
				save: false,
			},
			gridEvents: {
				cellDblclick: ({ row }) => {
					this.edit(row);
				},
				add: () => {
					this.openSave();
				},
				edit: ({ button }) => {
					this.edit(button.selectRecords[0]);
				},
			},
		};
	},
	methods: {
		openSave: function () {
			this.dialog.save = true;
			this.$nextTick(() => {
				this.$refs.saveDialog.open();
			});
		},
		handleSuccess() {
			this.$refs.xGrid1.refresh();
		},
		edit(item) {
			this.dialog.save = true;
			this.$nextTick(() => {
				this.$refs.saveDialog.open("edit").setData(item);
			});
		},
	},
};
</script>
